using System;
using System.Collections.Generic;
using System.Text;

namespace Pixysoft.Framework.Remoting
{
    class SettingHelper
    {
        RemotingConfiguration mappings = null;

        CacheRemotingConfiguration settings = new CacheRemotingConfiguration();

        private static volatile SettingHelper instance;

        private static object syncRoot = new Object();

        private static SettingHelper Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (syncRoot)
                    {
                        if (instance == null)
                        {
                            instance = new SettingHelper();
                        }
                    }
                }
                return instance;
            }
        }

        public static RemotingConfiguration Mappings
        {
            get
            {
                if (Instance.mappings != null)
                    return Instance.mappings;

                lock (syncRoot)
                {
                    if (Instance.mappings != null)
                        return Instance.mappings;

                    try
                    {
                        Instance.mappings = Pixysoft.Framework.Configurations.Configuration.GetConfiguration<RemotingConfiguration>();
                    }
                    catch
                    {
                        Instance.mappings = new RemotingConfiguration();
                    }

                    if (Instance.mappings == null)
                        Instance.mappings = new RemotingConfiguration();

                    return instance.mappings;
                }
            }
        }

        public static CacheRemotingConfiguration Configuration
        {
            get
            {
                return Instance.settings;
            }

        }
    }
}
